package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.ArrangePeriod;
import com.dragon.repository.entity.ArrangePersonnel;
import com.dragon.repository.entity.AttendanceArrange;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class AttendanceArrangeVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "班次类型：1固定班次2自由班次3外勤班次")
    private Integer shiftType;

    @ApiModelProperty(value = "班次名称")
    private String shiftName;

    @ApiModelProperty(value = "时间表list")
    private List<ArrangePeriod> periodList;

    @ApiModelProperty(value = "人员表")
    private List<Integer> adminIds;

    @ApiModelProperty(value = "打卡日期")
    private String punchClock;

    @ApiModelProperty(value = "开始打卡日期")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date beginTime;

    @ApiModelProperty(value = "日期（周一到周日）")
    private String recurry;

    @ApiModelProperty(value = "是否跳过法定节假日打卡：0是1否")
    private Integer automaticLeave;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static AttendanceArrange convert(AttendanceArrangeVO vo) {
        AttendanceArrange entity = new AttendanceArrange();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<AttendanceArrange> convertList(List<AttendanceArrangeVO> list) {
        List<AttendanceArrange> resultList = new ArrayList<>();
        for (AttendanceArrangeVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
